<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Zepto assets functional test</title>
  <link rel="stylesheet" href="../test.css">
  <meta name="viewport" content="maximum-scale=1,initial-scale=1,user-scalable=0">
  <script src="../../src/zepto.js"></script>
  <script src="../../src/ie.js"></script>
  <style>
    #container div {
      margin: 2px;
      padding: 2px;
      display: block;
      background-color: #ccc;
    }
    img {
      margin: 0;
      height: 100px;
      vertical-align: middle;
    }
  </style>
</head>
<body>
  <h1>Zepto assets functional test</h1>

  <div id="browser"></div>

  <ul>
    <li><a href="?without">Run without the assets plugin</a></li>
    <li><a href="?with">Run with the assets plugin</a></li>
    <li><a href="?">Stop</a></li>
  </ul>

  <p>When you run this test without the assets plugin, Mobile Safari will stop loading after on average 8 images (that's on the iPad with 1 MB images). It might also crash.</p>
  <p><strong>PLEASE NOTE:</strong> You <strong>must restart Safari</strong> between runs (click the home button to return to the home screen, double-click the home button, tap-and-hold the Safari icon, then tap the minus badge).</p>

  <div id="container"></div>

  <script>
    var prefix = 'http://stuff.vandervossen.net/temporary/zepto_assets_test/sintel-',
        mode = window.location.search.slice(1),
        timeout,
        i
    if (mode === 'with') {
      document.write('<script src="../src/assets.js"></s'+'cript>')
      document.write('RUNNING WITH ASSETS PLUGIN')
    }
    if (mode !== '') {
      i = 1
      ;(function frame() {
        $('#image' + (i - 4)).remove()
        $('#container').prepend('<div>' + i + ': <img id="image' + i + '" src="' + prefix + i + '.jpg"></div>')
        if (i++ < 51) timeout = setTimeout(frame, 6000)
      })()
    }

    $('#browser').text(navigator.userAgent)
  </script>
</body>
</html>
